package com.ruike.alisurface.ui.adapters;

import android.content.Context;
import android.graphics.Color;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.ruike.alisurface.R;
import com.ruike.alisurface.bean.replenBean;
import com.voodoo.lib_logcat.L;
import com.voodoo.lib_utils.imageLoader.GlideImageLoader;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class ReplenAdapter extends BaseQuickAdapter<replenBean.RowsBean, BaseViewHolder> {

    Context mContext;

    public ReplenAdapter(@Nullable List<replenBean.RowsBean> data, Context context) {
        super(R.layout.replenishment_item, data);
        this.mContext = context;
    }

    @Override
    protected void convert(@NotNull BaseViewHolder helper, replenBean.RowsBean rowsBean) {
        GlideImageLoader.getInstance().loadImage(mContext, rowsBean.getProductimg(), helper.getView(R.id.replen_img));
        helper.setText(R.id.replen_slot, rowsBean.getIndex() + "");
        helper.setText(R.id.replen_price, "￥ " + rowsBean.getPrice() + "");
        helper.setText(R.id.replen_current_inventory, rowsBean.getCount() + "");
        helper.setText(R.id.replen_maximum_inventory, rowsBean.getMax_count() + "");

        helper.setText(R.id.replen_product_name, rowsBean.getProduct_name());

        TextView replen_slot_status = helper.getView(R.id.replen_slot_status);
        ImageView status_img = helper.getView(R.id.replen_slot_status_img);
        replen_slot_status.setText(rowsBean.getSlot_state_str());

        if (rowsBean.getSlot_state_id() == 22001) {
            status_img.setImageResource(R.drawable.replen_status_ky);
            replen_slot_status.setTextColor(getContext().getResources().getColor(R.color.sky_green_color));
        } else if (rowsBean.getSlot_state_id() == 22002) {
            status_img.setImageResource(R.drawable.replen_status_ty);
            replen_slot_status.setTextColor(getContext().getResources().getColor(R.color.sky_grey_color));
        } else if (rowsBean.getSlot_state_id() == 22003) {
            status_img.setImageResource(R.drawable.replen_status_gz);

            replen_slot_status.setTextColor(getContext().getResources().getColor(R.color.sky_red_color));

        }
        int position = helper.getLayoutPosition();

    }
}
